package com.markhsiu.common;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * 常量工具
 * 
 */
public class ConstantUtil {

	
	public static final String WEB_ROOT =
			    System.getProperty("user.dir") + File.separator  + "webroot";

	public static final String Encoding = "UTF-8";
	
    /**
     * I/O线程数经验值是[CPU核数 + 1，CPU核数*2 ]之间
     * 当前系统的进程*2
     */
    private static int workerThreads = Runtime.getRuntime().availableProcessors() ;
    
    
    public static int getWorkerThreads() {
        return workerThreads;
    }

    public static void setWorkerThreads(int workers) {
        workerThreads = workers;
    }
    
    
    public static String decodeUTF(String src) throws UnsupportedEncodingException{
		return  URLDecoder.decode(src,Encoding);
    }
 
    public static String bytesUTF(byte[] bytes) throws UnsupportedEncodingException{
		return  new String(bytes, Encoding);
    }
}
